package com.cygsunri.parkingsuff.controller;


import com.cygsunri.commonutils.response.ResultWrapper;
import com.cygsunri.parkingsuff.entity.EduTeacher;
import com.cygsunri.parkingsuff.feign.WarnFeignService;
import com.cygsunri.parkingsuff.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author hanyuan
 * @since 2021-03-30
 */
@RefreshScope  //动态从配置中心读取配置
@RestController
@RequestMapping("/tempOne")
public class EduTeacherController {

    @Autowired
    private EduTeacherService eduTeacherService;

    @Autowired
    private WarnFeignService warnFeignService;

    @Value("${coupon.user.name}")
    private String name;
    @Value("${coupon.user.age}")
    private Integer age;


    /**
     * 数据源
     * @return
     */
    @GetMapping("/testList")
    public List<EduTeacher> list(){
        return eduTeacherService.list(null);
    }

    /**
     * 测试服务之间的接口调用
     * @return
     */
    @GetMapping("/TestFeign")
    public ResultWrapper<Object> listTest(){
        ResultWrapper<Object> r = warnFeignService.listTest();
        return ResultWrapper.ok("测试服务之间的接口调用成功",r.getData());
    }

    @RequestMapping("/configTest")
    public ResultWrapper<Object> getConfigInfo(){
        Map<String,Object> configMap = new HashMap<>();
        configMap.put("temp",name);
        configMap.put("age",age);
        return ResultWrapper.ok("动态从配置中心读取信息成功",configMap);
    }

}

